package org.esprit.ocm.server.dao.impl;

import java.util.List;

import org.esprit.ocm.dto.impl.AwsCredentialsDto;
import org.esprit.ocm.dto.impl.ServerDto;
import org.esprit.ocm.server.dao.AwsCredentialsDao;
import org.esprit.ocm.server.dao.hibernate.BaseDaoHibernate;
import org.hibernate.Query;
import org.hibernate.Session;

public class AwsCredentialsDaoImpl extends BaseDaoHibernate<AwsCredentialsDto> implements AwsCredentialsDao {

	public AwsCredentialsDaoImpl(Class<AwsCredentialsDto> _type) {
		super(_type);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void initDao() throws Exception {
		// TODO Auto-generated method stub
		super.initDao();
	}
	
	public AwsCredentialsDto findCredentialByServer(ServerDto _o) {
		Session session = getSession();
		Query query = session.createQuery("from AwsCredentialsDto a where a.server.idServer = :server");
		query.setParameter("server", _o.getIdServer());

		return (AwsCredentialsDto) query.uniqueResult();
	}

}
